package com.mpower.scheduled;

import java.util.List;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.mpower.directpay.DoDirectPayment;
import com.slayer.model.CreditCard;
import com.slayer.service.CreditCardLocalServiceUtil;

public class ScheduledPayment extends MVCPortlet implements MessageListener {
	
		public void receive(Message arg0) throws MessageListenerException {
				DoDirectPayment doDirectPayment=new DoDirectPayment();
				List<CreditCard> profiles = null;
				String result = null;
				
				try {
					profiles = CreditCardLocalServiceUtil.getCreditCards(0, 1);
				} catch (SystemException e) {
					e.printStackTrace();
				}
		
				System.out.println("############--Transaction Start--#########");
		
			for(CreditCard profile : profiles){
				
						String expDate=profile.getCardExpMonth()+profile.getCardExpYear();
						result=doDirectPayment.DoDirectPaymentCode("sale", "10", "visa",profile.getCardNumber(),expDate ,profile.getCardCVV(), profile.getCardFirstName(),profile.getCardLastName(),"Lalbag", "Bangalore","KA","560095", "US");
					}
				System.out.println("Your transaction has "+result);	
			}
	}